<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>首页</h2>
欢迎来到首页
<input type="button" value="查找用户"/>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
    $(function(){
        $(':button').on('click', function(){
            //获取token
            let token = localStorage.getItem("token");
            //发送请求，将token带回后台
            $.ajax({
                url: 'find',
                type: 'get',
                headers: {
                    'auth' : token
                },
                success: function (result) {
                    if(result.code === 401) {
                        alert(result.message);
                        location.href = 'login.html';
                    } else {
                        alert(result.data);
                        localStorage.removeItem("token");
                    }
                }
            });
        });
    })
</script>
</body>
</html>